//<template>
  <div>
    class
     <el-button type="primary" @click="tj">添加</el-button>
 <el-button type="text" @click="dialogVisible = true">点击打开 Dialog</el-button>

<el-dialog
  title="提示"
  :visible.sync="dialogVisible"
  width="30%"
  :before-close="handleClose">
  <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
<el-form-item label="日期" prop="id">
    <el-input v-model="ruleForm.id"></el-input>
  </el-form-item>
  <el-form-item label="姓名" prop="name">
    <el-input v-model="ruleForm.name"></el-input>
  </el-form-item>
  <el-form-item label="地址" prop="city">
    <el-input v-model="ruleForm.city"></el-input>
  </el-form-item>
  </el-form>
  <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
  </span>
</el-dialog>
       
    
     <el-table
      :data="tableData"
      style="width: 100%">
      <el-table-column
        prop="id"
        label="日期"
        width="180">
      </el-table-column>
      <el-table-column
        prop="name"
        label="姓名"
        width="180">
      </el-table-column>
      <el-table-column
        prop="city"
        label="地址">
      </el-table-column>
    <el-table-column
      fixed="right"
      label="操作"
      width="100">
      <template slot-scope="scope">
        <el-button @click="handleClick(scope.row)" type="text" size="small">删除</el-button>
        <el-button @click="handledel(scope.row)" type="text" size="small">编辑</el-button>
      </template>
    </el-table-column>
    
  
    </el-table>
  </div>
</template>

<script>
import {mapState,mapMutations,mapActions} from 'vuex'
import axios from 'axios'
import * as api from '../../api/list'
export default {
data(){
  return {
      tableData: [],
      dialogVisible: false,
       ruleForm: {
          name: '',
          id: '',
          city: '',
        
          delivery: false,
        },
      rules: {
         id: [{ required: true, message: '日期', trigger: 'blur' }],
         name: [{ required: true, message: '名字', trigger: 'blur' }],
         city: [{ required: true, message: '城市', trigger: 'blur' }],
      }
  };
},created(){
  axios.get('/list', {
    params: {}
  }).then((ret) => {
    console.log(ret.data.data)
    this.tableData=(ret.data.data)
  })
},
methods:{
  sc(e){
    // let t=e.target.parentElement.parentElement
    console.log(e);
  },
   handledel(row) {
        console.log(row,'bj');
        this.ruleForm={
          id:"",
          name:"",
          city:""
        },
          this.dialogVisible= true;
           this.ruleForm=row
       
      },
      tj(){console.log(123);
      this.dialogVisible= true;
        this.ruleForm={
          id:"",
          name:"",
          city:""
        }
        this.tableData.unshift(this.ruleForm)
      },
      handleClick(row){
         console.log(row.id,'sc');
         this.tableData.forEach((item,index) => {
          if(item.id===row.id){
            this.tableData.splice(index, 1)
          }
         })
      },
        handleClose(done) {
        this.$confirm('确认关闭？')
          .then(_ => {
            done();
          })
          .catch(_ => {});
      }
    
         
}
}
</script>

<style>

</style>